# include <bits/stdc++.h>
using namespace std;
const long long mike = 1000000007;

inline long long gn() {
    long long k = 0, f = 1;
    char c = getchar();
    for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
    return k * f;
}

struct mix {
    long long a[5][5];
    mix() {
        memset(a, 0, sizeof(a));
    }
    void output() {
        for(long long i = 0; i < 4; i++) {
            for(long long j = 0; j < 4; j++)
                printf("%lld ", a[i][j]);
            putchar('\n');
        }
    }
    mix operator *(const mix &b) const {
        mix c;
        for(long long i = 0; i < 4; i++)
            for(long long j = 0; j < 4; j++)
                for(long long k = 0; k < 4; k++)
                    c.a[i][j] = (c.a[i][j] + a[i][k] * b.a[k][j]) % mike;
        return c;
    }
};

mix fast_pow(mix a, long long k) {
    mix ans;
    for(long long i = 0; i < 4; i++) ans.a[i][i] = 1;
    if(k == 0) return ans;
    for(; k; k >>= 1) {
        if(k & 1) {
            ans = ans * a;
        }
        a = a * a;
    }
    return ans;
}

int main() {
    freopen("fibsqr.in", "r", stdin);
    freopen("fibsqr.out", "w", stdout);
    mix a, b;
    long long n = gn();
    a.a[0][0] = 1, a.a[0][1] = 1, a.a[0][2] = 1, a.a[0][3] = 2;
    a.a[1][0] = 0, a.a[1][1] = 1, a.a[1][2] = 1, a.a[1][3] = 2;
    a.a[2][0] = 0, a.a[2][1] = 1, a.a[2][2] = 0, a.a[2][3] = 0;
    a.a[3][0] = 0, a.a[3][1] = 1, a.a[3][2] = 0, a.a[3][3] = 1;
    b.a[0][0] = 2;
    b.a[1][0] = 1;
    b.a[2][0] = 0;
    b.a[3][0] = 0;
    a = fast_pow(a, n - 1);
    b = a * b;
    cout << b.a[0][0] - 1 << endl;
}